package com.blocks.model;

import com.blocks.ScriptBlocksApplication;
import com.jme3.asset.AssetManager;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;

public class LightningNode extends Node {

    private ParticleEmitter emitter;
	private Material mat_red;
	private Vector3f vec = Vector3f.ZERO;
    
	public LightningNode(String name,Vector3f extent) {
		super(name);
		vec  = extent;
		initParticles();
	}
	private void initParticles()
	{
		emitter = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 1);
	    mat_red = new Material(ScriptBlocksApplication.getInstance().getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");	    
	    mat_red.setTexture("Texture", ScriptBlocksApplication.getInstance().getAssetManager().loadTexture("Effects/Lightning.png"));
	    emitter.setMaterial(mat_red);
	    emitter.setImagesX(2); emitter.setImagesY(2); // 2x2 texture animation
//	    emitter.setInitialVelocity(vec);
	    emitter.setGravity(0);
//	    emitter.setLowLife(0.5f);
	    emitter.setHighLife(3f);
	   // emitter.setVelocityVariation(0.3f);
	    emitter.setStartSize(vec.x);
	    emitter.setEndSize(vec.x);
	    emitter.setParticlesPerSec(100.0f);
	    //emitter.setSelectRandomImage(true);
	    this.attachChild(emitter);
	    emitter.emitAllParticles();	   
	   
	}


	


}
